package com.example.project.projectspringcloud.service.impl.sys;

import com.example.project.projectspringcloud.dao.sys.DictionaryMapper;
import com.example.project.projectspringcloud.entity.Page;
import com.example.project.projectspringcloud.entity.sys.Dictionary;
import com.example.project.projectspringcloud.service.BaseService;
import com.example.project.projectspringcloud.service.sys.SysDictionaryService;
import com.example.project.projectspringcloud.utils.RedisUtil;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(rollbackFor = Exception.class)
public class SysDictionaryServiceImpl extends BaseService<Dictionary, DictionaryMapper> implements SysDictionaryService {

    @Autowired
    private RedisUtil redisUtil;

    @Override
    public List<Dictionary> list(Dictionary dictionary, Page page) {
        if (page != null) {
            PageHelper.startPage(page.getPageNum(), page.getPageSize());
        }

        return super.mapper.selectAll(dictionary);
    }

    @Override
    public Dictionary get(Dictionary entity) {
        return super.mapper.selectOne(entity);
    }

    @Override
    public boolean save(Dictionary entity) {
        return super.save(entity);
    }


    @Override
    public boolean delete(Integer[] ids) {
        return super.delete(ids);
    }
}
